[LINUX] Clean up and clarify find_unbound_irq().
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 8 Dec 2006 09:19:37 +0000 (09:19 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 8 Dec 2006 09:19:37 +0000 (09:19 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c

index d596da3888d75eb676c4965ea4d093533b2da302..445cacf7852e151a1893ec69c53acf5af5f18eec 100644 (file)
@@ -244,24 +244,22 @@ asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
 
 static int find_unbound_irq(void)
 {
-       int irq;
+       static int warned;
+       int dynirq, irq;
 
-       /* Only allocate from dynirq range */
-       for (irq = DYNIRQ_BASE; irq < NR_IRQS; irq++)
+       for (dynirq = 0; dynirq < NR_DYNIRQS; dynirq++) {
+               irq = dynirq_to_irq(dynirq);
                if (irq_bindcount[irq] == 0)
-                       break;
+                       return irq;
+       }
 
-       if (irq == NR_IRQS) {
-               static int warned;
-               if (!warned) {
-                       warned = 1;
-                       printk(KERN_WARNING "No available IRQ to bind to: "
-                              "increase NR_IRQS!\n");
-               }
-               return -ENOSPC;
+       if (!warned) {
+               warned = 1;
+               printk(KERN_WARNING "No available IRQ to bind to: "
+                      "increase NR_DYNIRQS.\n");
        }
 
-       return irq;
+       return -ENOSPC;
 }
 
 static int bind_evtchn_to_irq(unsigned int evtchn)